package wallFactory.builders;

import mapControl.GraphicsMapControl;

import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.image.Texture.MagnificationFilter;
import com.jme.image.Texture.MinificationFilter;
import com.jme.image.Texture.WrapMode;
import com.jme.math.Vector3f;
import com.jme.scene.shape.Box;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;

public class NonDestWallBulider extends WallBuilder {

	TextureState ts;

	public NonDestWallBulider(GraphicsMapControl mapControl) {
		super(mapControl);
		ts = mapControl.getDisplay().getRenderer().createTextureState();
		Texture t = TextureManager.loadTexture(getClass().getClassLoader()
				.getResource("data/texturas/metal.jpg"),
				MinificationFilter.NearestNeighborLinearMipMap,
				MagnificationFilter.NearestNeighbor);
		t.setWrap(WrapMode.Repeat);
		ts.setTexture(t);

	}

	@Override
	public void buildModel() {

		Box box = new Box("mazeBox", Vector3f.ZERO.clone(), new Vector3f(
				mapControl.getTilesize(), mapControl.getTilesize(), mapControl
						.getTilesize()));

		box.setModelBound(new BoundingBox());
		box.updateModelBound();

		getWall().getNode().attachChild(box);
		getWall().getNode().generatePhysicsGeometry();
	}

	@Override
	public void buildTexture() {
		getWall().getNode().setRenderState(ts);
	}

	@Override
	public void locate(int row, int col) {
		super.locate(row, col);
		getWall().setName("NDW["+row+"]["+col+"]");
		mapControl.addNonDesWall(getWall());

	}

}
